package csen;

import java.util.logging.*;

public class CarStoreLog implements Observer {

	Logger logger = Logger.getLogger("CarStoreLog");
	FileHandler fh;

	public CarStoreLog(String logPath) {
		try {
			fh = new FileHandler("CarStoreLog.log");
			logger.addHandler(fh);
			SimpleFormatter formatter = new SimpleFormatter();
			fh.setFormatter(formatter);
			logger.info("Logul a fost pornit.");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public void update(String opperationType, Car car) {
		if ("add".equals(opperationType)) {
			logger.info("Masina " + car.toString()
					+ " a fost adaugata in magazin.");
		} else if ("remove".equals(opperationType)) {
			logger.info("Masina " + car.toString()
					+ " a fost retrasa din magazin.");
		} else if ("createOrder".equals(opperationType)) {
			logger.info("Masina " + car.toString() + " a fost comandata.");
		} else if ("cancelOrder".equals(opperationType)) {
			logger.info("Comanda masinii " + car.toString()
					+ " a fost anulata.");
		} else if ("approveOrder".equals(opperationType)) {
			logger.info("Masina " + car.toString() + " a fost cumparata.");
		}
	}
}
